home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume10 / roff17 < prev    next >
Encoding:
Text File  |  1990-01-19  |  5.5 KB  |  180 lines

  1. Newsgroups: comp.sources.misc
  2. organization: APT Technology, Inc.  San Jose, CA,  USA
  3. subject: v10i024: roff version 1.7
  4. from: brian@apt.UUCP (Brian Litzinger)
  5. Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  6.  
  7. Posting-number: Volume 10, Issue 24
  8. Submitted-by: brian@apt.UUCP (Brian Litzinger)
  9. Archive-name: roff17
  10.  
  11. [???  ++bsa]
  12.  
  13. Yet another absolutely useless program.  Just /bin/rm roff.shar
  14. and you live a much better life.
  15.  
  16. Maybe we should get a new moderator for this group. 8-)
  17.  
  18. This is an improved version of the roff script I wrote.  It has
  19. been enhanced by contributions from roff users. (As hard as it
  20. may be to believe someone actually found code by me useful)
  21.  
  22. roff, if you care, lets you encode the filters that a troff file
  23. must be passed through to be printed into the file itself.  Thus
  24. you won't have to remember if the document requires pic, or tbl,
  25. or pic and tbl and grap, and so on.
  26.  
  27. <>  Brian Litzinger @ APT Technology Inc., San Jose, CA
  28. <>  UUCP:  {apple,sun,pyramid}!daver!apt!brian    brian@apt.UUCP
  29. <>  VOICE: 408 370 9077      FAX: 408 370 9291
  30.  
  31. #! /bin/sh
  32. # This is a shell archive.  Remove anything before this line, then unpack
  33. # it by saving it into a file and typing "sh file".  To overwrite existing
  34. # files, type "sh file -c".  You can also feed this as standard input via
  35. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  36. # will see the following message at the end:
  37. #        "End of shell archive."
  38. # Contents:  README roff
  39. # Wrapped by brian@apt on Wed Jan 17 00:29:45 1990
  40. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  41. if test -f 'README' -a "${1}" != "-c" ; then 
  42.   echo shar: Will not clobber existing file \"'README'\"
  43. else
  44. echo shar: Extracting \"'README'\" \(2007 characters\)
  45. sed "s/^X//" >'README' <<'END_OF_FILE'
  46. XThis is version 1.7 of roff.
  47. X
  48. XIt incorporates some new features that were contributed by other
  49. Xuser's of roff.
  50. X
  51. Xroff is a script that allows you to encode the filters that a troff
  52. Xfile must be passed through along with which macro packages to use
  53. Xin the document file.
  54. X
  55. XTo use roff you simply add a roff command line as the first line of
  56. Xyour document file.  Then when you wish to print out the document
  57. Xyou can simply enter
  58. X
  59. X    roff filename
  60. X
  61. Xroff will generate the correct command stream to print the file.
  62. X
  63. Xthe roff command line is basically a line of text that is passed to
  64. Xeval(1).  Its format is as follows:
  65. X
  66. X.\" exec tbl | pic | eroff -mm
  67. X
  68. Xthe '.\"' is a troff/nroff comment delimeter.  The 'exec' helps identify
  69. Xthis line as a roff command line.
  70. X
  71. Xthe rest of the line is the filters, packages, and macros that the
  72. Xdocument file should be passed through.  Other examples are:
  73. X
  74. X.\" exec eroff
  75. X
  76. X.\" exec tbl | eroff -mm -mapt
  77. X
  78. XIf you look at the roff script you will notice that we strip off the
  79. Xfirst line of the document file (the roff command line) before we
  80. Xpipe the document through the rest of the filters.  This is due to
  81. Xa previous bout of ignorance on the part of the author, and must now
  82. Xremain with us forever to maintain compatibility with older roff command
  83. Xlines.
  84. X
  85. XYou might also notice a reference to '$F'.  This is necessary for us
  86. Xto be compatible with another older roff command line format.
  87. X
  88. XIf you are a user of the previous version of roff the following
  89. Xenhancements have been added:
  90. X
  91. X1. the roff command line of the previous version relied on characters
  92. Xbeing in particular locations.  I.E. exec had to occur as the forth
  93. Xcharacter of the roff line.  This requirement is gone, as the new
  94. Xroff treats the entries as fields seperated by arbitrary amounts
  95. Xof white space.
  96. X
  97. X2. #!/bin/sh was added to the beginning for csh users.
  98. X
  99. X3. roff now takes the '-p' argument to pass the file to other troff
  100. Xprocessors such as psroff.
  101. X
  102. Xbugs:
  103. X
  104. X    I sure wish roff could take input from stdin.
  105. END_OF_FILE
  106. if test 2007 -ne `wc -c <'README'`; then
  107.     echo shar: \"'README'\" unpacked with wrong size!
  108. fi
  109. # end of 'README'
  110. fi
  111. if test -f 'roff' -a "${1}" != "-c" ; then 
  112.   echo shar: Will not clobber existing file \"'roff'\"
  113. else
  114. echo shar: Extracting \"'roff'\" \(1163 characters\)
  115. sed "s/^X//" >'roff' <<'END_OF_FILE'
  116. X#!/bin/sh
  117. X# roff by Brian E. Litzinger
  118. X# $Header: roff,v 1.7 90/01/17 00:19:18 brian Exp $
  119. X# Contributing Authors:
  120. X#     Jeff Goldstein, Svante Lindahl, Barry Schwartz
  121. X#
  122. X# Usage:  roff [ -p prefix ] [ options ] file-name ...
  123. X# The troff-prefix is the first part of the troff command name, the
  124. X# second part being "roff".  For example, type
  125. X#    roff -f ps file
  126. X# to run the file through psroff and the appropriate filters and macros.
  127. X
  128. XTROFF=eroff
  129. XPREFIX=e
  130. XTMP=/tmp/roff$$
  131. Xif [ $# -lt 1 ] ; then
  132. X    echo "Usage:  `basename $0` [ -p prefix ] [options] files"
  133. X    exit 2
  134. Xfi
  135. Xwhile [ -n "$1" ] ; do
  136. X    case "$1" in
  137. X    -p)
  138. X        shift
  139. X        PREFIX=$1
  140. X    ;;
  141. X    -*)
  142. X        args="$args $1"
  143. X    ;;
  144. X    *)
  145. X        command_line="`sed -e 1q $1`"
  146. X        b="`echo $command_line | cut -f2 -d' '`"
  147. X        if [ "$b" != "exec" ] ; then
  148. X        echo "$1 not roff format file!"
  149. X        exit 2
  150. X        fi
  151. X        command="`echo $command_line | cut -f3- -d' '"
  152. X        d="sed -e 1d $1 |"
  153. X        for i in $command ; do
  154. X        if [ "$i" = '$F' ] ; then
  155. X            true
  156. X        else
  157. X            if [ "$i" = "$TROFF" ] ; then
  158. X            d="$d ${PREFIX}roff $args"
  159. X            else
  160. X            d="$d $i"
  161. X            fi
  162. X        fi
  163. X        done
  164. X        #echo $d
  165. X        eval $d
  166. X    ;;
  167. X    esac
  168. X    shift
  169. Xdone
  170. END_OF_FILE
  171. if test 1163 -ne `wc -c <'roff'`; then
  172.     echo shar: \"'roff'\" unpacked with wrong size!
  173. fi
  174. chmod +x 'roff'
  175. # end of 'roff'
  176. fi
  177. echo shar: End of shell archive.
  178. exit 0
  179.  
  180.